﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using TripleClasses;
using System.Collections.Generic;

namespace UnitTests
{
    [TestClass()]
    public class EGNEXtractorTest
    {
       [TestMethod()]
        public void ExtractTriplesFromOverflowTextTest()
        {
            string text = @"This is a list of triples: (1, 2, 3); (112,asd123,123,123)(22,33,44) and (1,2,3). This is not a triple: (1,2). This is also not a triple: [1,2,3]. Not that this is triple: ( 112312312321323, 2, 3 ).";
            List<Triple> actual = EGNEXtractor.ExtractTriplesFromText(text);
            List<Triple> expected = new List<Triple>(
                new Triple[] { new Triple(1, 2, 3), new Triple(22, 33, 44), new Triple(1, 2, 3)});
            actual = EGNEXtractor.ExtractTriplesFromText(text);
            bool foundDifference = false;
            if (actual.Count != expected.Count)
            {
                foundDifference = true;
            }
            if (!foundDifference)
            {
                for (int i = 0; i < expected.Count; i++)
                {
                    if (expected[i].CompareTo(actual[i]) != 0)
                    {
                        foundDifference = true;
                        break;
                    }
                }
            }
            Assert.IsFalse(foundDifference);
        }

        [TestMethod()]
        public void ExtractTriplesFromTextTest()
        {
            string text = @"This is a list of triples: (1, 2, 3); (112,asd123,123,123)(22,33,44) and (1,2,3). This is not a triple: (1,2). This is also not a triple: [1,2,3]. Not that this is triple: ( 1121323, 2, 3 ).";
            List<Triple> actual = EGNEXtractor.ExtractTriplesFromText(text);
            List<Triple> expected = new List<Triple>(
                new Triple[] { new Triple(1, 2, 3), new Triple(22, 33, 44), new Triple(1, 2, 3), new Triple(1121323, 2, 3) });
            actual = EGNEXtractor.ExtractTriplesFromText(text);
            bool foundDifference = false;
            if (actual.Count != expected.Count)
            {
                foundDifference = true;
            }
            if (!foundDifference)
            {
                for (int i = 0; i < expected.Count; i++)
                {
                    if (expected[i].CompareTo(actual[i]) != 0)
                    {
                        foundDifference = true;
                        break;
                    }
                }
            }
            Assert.IsFalse(foundDifference);
        }
    }
}
